<?php

namespace app\model;

class PostModel extends BaseModel
{
    protected $table = 'post';
    
    protected $casts = [
        'media' => 'array',
        'created_at' => 'timestamp',
        'updated_at' => 'timestamp',
    ];
    
    public function user()
    {
        return $this->belongsTo(UsersModel::class, 'user_id');
    }
    
    public function topic()
    {
        return $this->belongsTo(TopicModel::class, 'topic_id');
    }
    
    public function comments()
    {
        return $this->hasMany(CommentModel::class, 'post_id');
    }

    public function discuss()
    {
        return $this->belongsTo(DiscussModel::class, 'discuss_id');
    }
}